<?php
require_once ROOT_APPLICATION_MODULES_ADMIN_MODELS.DS."Users.php";
class Zend_View_Helper_ShowPageIndex {
    public function showPageIndex($view) {
		$modelUser = new End_Models_Users();
    	$page = $view->Pages;
    	$str='';
        $str .= '<table id="product-table" border="0" cellpadding="0" cellspacing="0" width="100%">';
        $str .= '<tr>';
        $str .= '<th class="table-header-repeat line-left minwidth-1"><a href="">Tên trang</a></th>';
        
        $str .= '<th class="table-header-repeat line-left minwidth-1"><a href="">Ngày tạo</a></th>';
        $str .= '<th class="table-header-repeat line-left minwidth-1"><a href="">Người tạo</a></th>';
        $str .= '<th class="table-header-repeat line-left minwidth-1"><a href="">Kích hoạt</a></th>';
        $str .= '<th class="table-header-repeat line-left minwidth-1"><a href="">Id</a></th>';
        $str .= '<th class="table-header-options line-left minwidth-2"><a href="">Thao tác</a></th>';
        $str .= '</tr>';

        $i=0;
        $active='';
        $user_name='';
        foreach ($page as $page) {
        	if($page->is_active==1)
        		$active='Đã kích hoạt';
        	else 
        		$active='Chưa kích hoạt';
        	if($page->user_id == 0||$page->user_id == null)
        		$user_name='';
        	else 
        		$user_name=$modelUser->_getUserName($page->user_id);
            if($i>=1)
                $i=0;
            else
                $i++;
            
            if($i==1)
                $str .= '<tr>';
            else 
                $str .= '<tr class="alternate-row">';
                
            $str .='<td>'.$page->name.'</td>';
            
            $str .='<td>'.$page->created_date.'</td>';
            $str .='<td>'.$user_name.'</td>';
            $str .='<td>'.$active.'</td>';
            $str .='<td>'.$page->page_id.'</td>';
            $str .= '<td class="options-width">';
            $str .= '<a title="Sửa" class="icon-1 info-tooltip" href="'.$view->url(array('controller'=>'page', 'action'=>'edit', 'page_id'=>$page->page_id)).'"></a> ';
            $str .= '<a title="Thêm" class="icon-3 info-tooltip" href="'.$view->url(array('controller'=>'page', 'action'=>'add','page_id'=>$page->page_id)).'"></a>';
            $str .= '<a title="Kích hoạt" class="icon-5 info-tooltip" href="'.$view->url(array('controller'=>'page','action'=>'active','page_id'=>$page->page_id)).'"></a>';
            $str .= '<a title="Xóa" class="icon-2 info-tooltip" href="'.$view->url(array('controller'=>'page', 'action'=>'delete','page_id'=>$page->page_id)).'"></a></td>';
            $str .='</tr>';
        }
        $str .= '</table>';
        
        return $str; 

    }
}